<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>浏览器程序设计</title>
</head>
<body>
<script>
    //    var history = 'Hello, BOM!';
    //    window.history.back();
    //    error; string objects don't hava a back() medhod

    var myVariable = 'Hello, World!';
    alert(window.myVariable);

    history.go(-2);
    history.go(3);

    location.replace('myPage.html');
    location.href = 'myPage.html';

    function success(position) {
        alert('I have your now! ' + position);
        var crds = position.coords;
        var latiude = crds.latitude;
        var longitude = crds.longitude;
        var altitude = crds.altitude;
        var speed = crds.speed;
        alert(latiude + longitude + altitude + speed);
    }
    function error(e) {
        alert('Un oh, something went wrong ' + e.message);
    }
    navigator.geolocation.getCurrentPosition(success, error);

    //    <img name='myImage' src='usa.gif' alt='USA' />
    var myImage2 = document.images[1];
    document.write(myImage2);

    if (navigator.geolocation) {
        //    use geolocation
    }

    if (typeof navigator.geolocation != 'undefined') {
        //    use geolocation
    }
</script>
</body>
</html>